#include "interface.h"

GtkWidget*
create_conn_fail (char *msg)
{
  GtkWidget *conn_fail;
  GtkWidget *dialog_vbox1;
  GtkWidget *labelConnFail;
  GtkWidget *dialog_action_area1;
  GtkWidget *okbutton1;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  conn_fail = gtk_dialog_new ();
  gtk_tooltips_set_tip (tooltips, conn_fail, "Connection Failed!", NULL);
  gtk_window_set_title (GTK_WINDOW (conn_fail), "w3live - Connection Failed");
  gtk_window_set_position (GTK_WINDOW (conn_fail), GTK_WIN_POS_MOUSE);
  gtk_window_set_modal (GTK_WINDOW (conn_fail), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (conn_fail), 300, 150);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (conn_fail), TRUE);

  dialog_vbox1 = GTK_DIALOG (conn_fail)->vbox;
  gtk_widget_show (dialog_vbox1);

  labelConnFail = gtk_label_new (msg);
  gtk_widget_show (labelConnFail);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), labelConnFail, TRUE, TRUE, 0);
  gtk_label_set_line_wrap (GTK_LABEL (labelConnFail), TRUE);

  dialog_action_area1 = GTK_DIALOG (conn_fail)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (conn_fail), okbutton1, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

  gtk_signal_connect (GTK_OBJECT (conn_fail), "close",
                      GTK_SIGNAL_FUNC (conn_close),
                      GTK_OBJECT(conn_fail));
  gtk_signal_connect (GTK_OBJECT (conn_fail), "destroy",
                      GTK_SIGNAL_FUNC (conn_close),
                      GTK_OBJECT(conn_fail));
  gtk_signal_connect (GTK_OBJECT (okbutton1), "clicked",
                      GTK_SIGNAL_FUNC (conn_close),
                      GTK_OBJECT(conn_fail));

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (conn_fail, conn_fail, "conn_fail");
  GLADE_HOOKUP_OBJECT_NO_REF (conn_fail, dialog_vbox1, "dialog_vbox1");
  GLADE_HOOKUP_OBJECT (conn_fail, labelConnFail, "labelConnFail");
  GLADE_HOOKUP_OBJECT_NO_REF (conn_fail, dialog_action_area1, "dialog_action_area1");
  GLADE_HOOKUP_OBJECT (conn_fail, okbutton1, "okbutton1");
  GLADE_HOOKUP_OBJECT_NO_REF (conn_fail, tooltips, "tooltips");

  gtk_widget_grab_focus (conn_fail);
  return conn_fail;
}

void
conn_close                             (GtkButton       *button,
                                        gpointer         user_data)
{
	gtk_widget_destroy((GtkWidget *)user_data);
}
